package com.wfx.controller;


import com.wfx.entity.PageDTO;
import com.wfx.entity.PageResult;
import com.wfx.entity.Result;
import com.wfx.entity.WxbGoods;
import com.wfx.service.IWxbGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhu
 * @since 2021-01-21
 */
@RestController
@CrossOrigin
@RequestMapping("/goods")
@Api(description = "商品管理")
public class WxbGoodsController {

    @Autowired
    private IWxbGoodsService iWxbGoodsService;

    @PostMapping("/search")
    @ApiOperation("分页+条件")
    public PageResult<WxbGoods> search(@RequestBody @ApiParam("分页条件") PageDTO<WxbGoods> pageDTO){
        if (pageDTO == null) {
            pageDTO.setPage(1);
            pageDTO.setLimit(5);
        }
        return iWxbGoodsService.search(pageDTO);
    }

    @PostMapping("/update")
    @ApiOperation("修改状态")
    public Result update(@RequestBody @ApiParam("修改参数") WxbGoods wxbGoods){
        return iWxbGoodsService.update(wxbGoods);
    }




}
